<?php
class m_sppd_kota_model extends CI_Model{ 

	function sppd_model()
	{
		parent::__construct();
	}
	function getListKota($limit='',$offset=''){
			$menus='';
			$judul=$this->input->post('judul');
			$status=$this->session->userdata('STATUS');
			$query=$this->db->query("select  * ,m_kota.id as sppdid from m_kota
   		 	ORDER BY m_kota.id DESC");
			 if ($query->num_rows() > 0) {
				foreach ($query->result() as $data) {
					$menus[]=$data;
				}
				return $menus;
			}

		}
	 
	function count_kota($id=''){
		$jumlah='';
		$status=$this->session->userdata('STATUS');
		$query=$this->db->query("select count(1) as jumlah from m_kota");
			 if ($query->num_rows() > 0) {
				foreach ($query->result() as $data) {
				$jumlah=$data->jumlah;
				}
				return $jumlah;
			}
	}
	 
	function getKota($id=''){
		 
			$query=$this->db->query("select * from m_kota
			where id='$id'");
			 if ($query->num_rows() > 0) {
				foreach ($query->result() as $row) {
					$table=$row->nama_kota;	
				}
				return $table;
			}
			 	
			
	}
	 
	function simpan($id=''){
		$txtkota=$this->input->post('txtkota');
		$data=array(
	 	 'nama_kota'=>$txtkota,
		);
		if($id!='0'){
		$this->db->query("update m_kota set nama_kota='$txtkota' where id='$id'");	 } else {
		$this->db->trans_start();
		$this->db->insert('m_kota',$data);
		$this->db->trans_complete(); 
		}
		
	}	
    
	 
	function delete($id=''){
		$this->db->delete('artikel', array('id' => $id)); 
		echo"Sukses Hapus Data...";
	}
 
 
}
// END RiskIssue_model Class

/* End of file RiskIssue_model.php */
/* Location: ./application/models/RiskIssue_model.php */
?>